'''
Created on Apr 28, 2012
TC ID: Ecom_5031
Desc: Kiem thu chuc nang cai dat mot Module
@author: lavang
'''
import unittest
from Functions.globalFunc import preCondition, readData, endCondition
from Functions.loginPageFunc import login
from HTMLTestRunner import HTMLTestRunner
import time
from Functions.moduleFunc import clickOnModule, clickOnLinkInstallModule,\
    installModule, isModuleInstalled

username=readData("username")
password=readData("password")
filePath="E:\\DA tot nghiep\\EcomProject\\"
fileName="module_empty"
path=filePath+fileName+".zip"
class Ecom_5031(unittest.TestCase):


    def setUp(self):
        preCondition(self)

    def test_Ecom_5031(self):
        print "Buoc 1: Dang nhap website"
        login(self,username,password)
        
        print "Buoc 2: Vao trang cai dat Module"
        clickOnModule(self)
        
        print "Buoc 3: Click vao Install Module"
        clickOnLinkInstallModule(self)
        
        print "Buoc 4: Cai dat Module"
        installModule(self,path)
        
        print "Buoc 4: Xac nhan cai dat Module thanh cong"
        self.assertTrue(isModuleInstalled(self,fileName), "Failed!")
        print "Passed! Module duoc cai dat thanh cong"
    
    def tearDown(self):
        endCondition(self)



if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5031)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Kiem thu chuc nang cai dat Module'
                    )
    runner.run(suite)